<?php
/**
 * Created by yujian
 * Date: 2018-10-12
 */

namespace app\admin\controller;


use think\Controller;

class Init extends Controller
{
    public $AdminId = 0;
    public function initialize()
    {
        parent::initialize();
        session([
            'prefix' => 'module',
            'type' => '',
            'auto_start' => true,
        ]);

        $seUser = session('?username') ? session('username'):0;
        $sePass = session('?password') ? session('password'):0;

        if($seUser){
            $hasname = db('adminusers')->where('ad_name',$seUser)->find();
            if($hasname){
                $realpass = $hasname['ad_password'];

                if($realpass==$sePass){
                    $this->AdminId = $hasname['ad_id'];
                    $seAdmin = $hasname['ad_name'];

                    $this->assign('seAdminId',$this->AdminId);
                    $this->assign('seAdmin',$seAdmin);
                }else{
                    $this->redirect('admin/login/index');
                }
            }else{
                $this->redirect('admin/login/index');
            }
        }else{
            $this->redirect('admin/login/index');
        }

    }
}